package com.ymttest.database.sqlwapper.shenqisettlement;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.GoodsOwnerSettlementBill;

public class GoodsOwnerSettlementBillWrapper {

	SqlManager manager;

    public GoodsOwnerSettlementBillWrapper() {
        manager = new SqlManager("shenqisettlement");
    }
    
    @SuppressWarnings("unchecked")
	public GoodsOwnerSettlementBill selectByPrimaryKey(Long id) {
    	    	
		List<GoodsOwnerSettlementBill> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.GoodsOwnerSettlementBillMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() == 0) {
			Logger.comment("goods_owner_settlement_bill没有数据");

			return null;
		}

		return result.get(0);
	}
    
    public int updateBillToNotPay(Long billId) {
    	
    	HashMap<String, Object> map = new HashMap<>();
    	
    	map.put("id", billId);
    	map.put("paid_settlement_amount", BigDecimal.ZERO);
    	map.put("payment_status", 0);
    	
		int count = manager
				.update("com.ymttest.database.mapping.shenqisettlement.GoodsOwnerSettlementBillMapper.updateBillToNotPay",
						map);
		manager.commit();
		
		return count;
    }
  
    public static void main(String[] args) {
    	
    	GoodsOwnerSettlementBillWrapper test = new GoodsOwnerSettlementBillWrapper();
    	
    	System.out.println(test.updateBillToNotPay(8L));
    }
}
